import { useEffect } from "react"
import { useAsync } from "./use-async"
import { Project } from '../project-list/list'
import { useHttp } from "./http"
import { cleanObject } from "."

export const useProject = (param:Partial<Project>) => {
    const client = useHttp()
    const { run, ...result} = useAsync<Project[]>()

    useEffect(() => {
        run(client("projects",{data: cleanObject(param)}))
    },[param])

    return result
}